/**
 * 
 */
package fr.ants.controller.listener;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JLabel;
import javax.swing.JSlider;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

/**
 * Listener for the panel Slider
 * 
 * @author Guillaume Ruscassie
 * 
 */
public class SliderPanelListener implements MouseListener, ChangeListener {

	/**
	 * label that need a update.
	 */
	private JLabel label;

	/**
	 * Build.
	 * @param label to update
	 */
	public SliderPanelListener(JLabel label) {
		this.label = label;
	}

	@Override
	public void stateChanged(ChangeEvent e) {
		JSlider slider = (JSlider) e.getSource();
		// update the value in the label.
		label.setText(Integer.toString(slider.getValue()));
	}

	@Override
	public void mouseClicked(MouseEvent e) {
		// do nothing

	}

	@Override
	public void mousePressed(MouseEvent e) {
		// do nothing

	}

	@Override
	public void mouseReleased(MouseEvent e) {
		JSlider slider = (JSlider) e.getSource();
		// update the value in the label.
		label.setText(Integer.toString(slider.getValue()));

	}

	@Override
	public void mouseEntered(MouseEvent e) {
		// do nothing

	}

	@Override
	public void mouseExited(MouseEvent e) {
		// do nothing

	}

}
